(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('apf.popup.invoice.invoiceDetail', invoiceDetail);
	invoiceDetail.$inject = [ '$scope', '$q', '$uibModalInstance', 'Constants', 'ajaxServiceFactory', 'dialogsModule', 'gridService', 'modalService', 'layoutConfig', 'validatorConfig', 'authService'];
	function invoiceDetail($scope, $q, $uibModalInstance, Constants, ajaxServiceFactory, dialogsModule, gridService, modalService, layoutConfig, validatorConfig, authService) {
		var ctrl = this;
		ctrl.dialogsModule = dialogsModule;
		ctrl.layoutConfig = layoutConfig;
		
		
		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['close'] || dialogsModule.btnCallback['close']() !== false) {
				$uibModalInstance.dismiss();
			}
		};
		
		ctrl.init = function() {
			authService.viewInvoice(dialogsModule.params.invoice).then(function(response) {
				ctrl.invoice = response.data || dialogsModule.params.invoice;
			}, angular.noop);
		};
	}
})(angular);
